//
//  Card.m
//  CardSwitchDemo
//
//  Created by Apple on 2016/11/9.
//  Copyright © 2016年 Apple. All rights reserved.
//

#import "SEGCardCell.h"
#import "SEGCardDataModel.h"

@interface SEGCardCell ()

@property (nonatomic, strong) UIImageView *imageView;
@end

@implementation SEGCardCell

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        
        self.layer.cornerRadius = 8.0f;
        self.layer.masksToBounds = true;
        [self.contentView addSubview:self.imageView];
    }
    return self;
}
- (void)setModel:(SEGAdvertismentModel *)model {
    NSString *urlString = [NSString stringWithFormat:@"%@%@",kClientImageRootURL,model.pic];
    UIImage *placeholderImage = [UIImage imageNamed:SEGPicName(@"pic_default_72_72")];
    [self.imageView setImageWithURL:[NSURL URLWithString:urlString] placeholderImage:placeholderImage];
}

-(void)layoutSubviews {
    [super layoutSubviews];
    self.imageView.frame = self.contentView.bounds;
}

-(UIImageView *)imageView {
    if (!_imageView) {
        _imageView = [[UIImageView alloc]init];
        _imageView.contentMode = UIViewContentModeScaleAspectFill;
        _imageView.layer.masksToBounds = YES;
    }
    return _imageView;
}
@end
